<?php
namespace app\home\controller;
use app\home\model\GoodsappraiseModel;
use think\Request;
use think\Controller;
use think\Session;
class Goodsassess extends Controller{
    /*立即评价
    */
    public function  assessGoods(){
        if(Request::instance()->isGet()){
           $order['goods_id'] = input('id');
           $order['order_id']=input('order');
//           $order['user_id'] = Session::get('USER.id');
           $this->assign('order',$order);
        }else{
            abort(404,'页面不存在');
        }
        return $this->fetch('goods_assess');
    }
    //图片上传
    public function uploadPic(){
        $file = request()->file('file');
        // 移动到框架应用根目录/public/uploads/ 目录下
        if($file){
            $info = $file->move(ROOT_PATH . 'public' . DS . 'upload/assess');
            if($info){
                // 成功上传后 获取上传信息
                // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
                $getSaveName = $info->getSaveName();
                /*评论内容数据*/
                print_r($getSaveName);
            }else{
                // 上传失败获取错误信息
                echo $file->getError();
            }
        }


    }
    /*
     * 评价内容写入数据库*/
    public function assessOrder(){
        $data=[
            'goods_id'=>input('goods_id'),
            'appraise_content'=>input('text'),
            'user_id'=>Session::get('USER.id'),
            'appraise_url'=>input('upload_url'),
            'appraise_time'=>time(),
        ];
        $app = [
          'id' => input('order_id'),
        ];
        $appraise = new GoodsappraiseModel();
        $status =  $appraise->goodsAppraise($data,$app);
        return $status;

    }
}